$(function(){
	//Ativa a grid e seta as propriedades
	jQuery("#gridRemessa").jqGrid({
		url:"extranet/Remessa/lista",//Url da requisacao ajax p/retornar os dados
		datatype: "json", //Tipo de dado retornado pela requisicao
		colNames:['Identifica&ccedil&atildeo','Data', 'Amostra', 'Exame',  ' Resposta',  'Metodologia','Kit Sorologia'], 
		colModel:[
   	          //definicao parametros p/os campos da grid
	   		{name:'idRemessa',index:'idRemessa', width:90,align:"center", sorttype:'int'},
	   		{name:'dataRemessa',index:'dataRemessa', width:80, align:"center", sorttype:'date', formatter:'date', datefmt:'d/m/Y'},
	   		{name:'idAmostra',index:'idAmostra', width:130, align:"center", sorttype:'number', search: false},
	   		{name:'resultadoexame', index:'resultadoexame', width:140, align:"center",search: false},
	   		{name:'resposta',index:'resposta', width:140, align:"center", search: false},
	   		{name: 'metodologia',index:'metodologia', width:130,align:"center", search: false},
	   		{name: 'KitSorologia', index:'KitSorologia', width:260, align:"center", sortable:false, search: false},
	   		
	   		
	   	],
   		rowNum:30, //qdte de registros listados inicialmente:
   		rowList:[10,20,30,40],
   		shrinkToFit: false, 
   		heigth: '400%',
   		width: 980,
                scroll:true,
   		pager: '#navRemessa',
   		sortname: 'dataRemessa',
   		multiselect: false, //creckbox select
   		viewrecords: true,
   		loadonce:true,
   		ignoreCase:true,
   		sortorder: "desc",
   		caption:"Remessa",
   		grouping:false,
		groupingView : {
				groupField : ['idRemessa'],
				groupColumShow : [false],
				groupText : ['<b>Remessa: {0} - {1} Resultado(s)</b>'],
				groupCollapse : true,
				groupOrder : ['asc'],
				groupSummary: [true],
				showSummaryOnHide: true,
				groupdataSorted : true
		},
		//footerrow: true,
		userdataOnFooter: true
	});
	//jQuery("#gridRemessa").jqGrid('navGrid','#gridRemessa',{export: true, add:false,edit:false,del:false});
	jQuery("#gridRemessa").jqGrid('filterToolbar',{stringResult:true, searchOnEnter:false});
	
	jQuery('#gridRemessa').jqGrid('navGrid','#navRemessa',{"edit":false,"add":false,"del":false,"search":false,"refresh":false,"view":false,"excel":false,"pdf":true,"csv":false,"columns":false},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"errorTextFormat":function(r){ return r.responseText;}},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"errorTextFormat":function(r){ return r.responseText;}},{"errorTextFormat":function(r){ return r.responseText;}},{"drag":true,"closeAfterSearch":true,"multipleSearch":true},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150});
	jQuery('#gridRemessa').jqGrid('navButtonAdd','#navRemessa',{id:'pager_pdf',caption:'Exportar',title:'Exportar em PDF',onClickButton : function(e)
		{
		    try {
		        jQuery("#gridRemessa").jqGrid('excelExport',{tag:'pdf', url:'extranet/Remessa/exportpdf'});
		    } catch (e) {
		        window.location= 'extranet/Remessa/exportPdf?oper=pdf';
		    }
		}, buttonicon:'ui-icon-print'});
});


